#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    ui->label->resize(200, 100);
    ui->label->move(350, 0);

    ui->btn2->setAutoFillBackground(0);

    ui->btn2->setCheckable(true);

    ui->widget->move(50, 350);

    ui->rbtn2->setChecked(true);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_btn2_clicked(bool checked)
{
    qDebug() << "on_btn2_clicked: " << checked << endl;
}

void MainWindow::on_btn2_pressed()
{
    qDebug() << "on_btn2_pressed" << endl;
}

void MainWindow::on_btn2_released()
{
    qDebug() << "on_btn2_released" << endl;
}

void MainWindow::on_btn2_toggled(bool checked)
{
    QList<QString> list ;
    list<<"战三"<<"李四"<<"王五"<<"赵六"<<"天气"<<"龙八";
    int size = list.size();
    QString txt = "";

    qDebug() << "on_btn2_toggled: " << checked << endl;
    if(checked){
        txt = "正在抽奖";
        ui->label->setText(txt);
        ui->btn2->setStyleSheet("background-image: url(:/icons/btn_pause_1.png);");
        ui->label->setStyleSheet("font-size:20px; color:red;");
    }
    else{
        int i = rand() % size;
        txt = "获奖观众是：";
        txt += list.at(i);
        ui->label->setText(txt);
         ui->btn2->setStyleSheet("background-image: url(:/icons/btn_play_1.png);");
         ui->label->setStyleSheet("font-size:40px; color:green;");
    }

}

void MainWindow::on_rbtn1_toggled(bool checked)
{
    if(checked)
        ui->label->setText("男");
    else
        ui->label->setText("女");
}
